// 引入request模块
import request from '@/utils/request'

// 分页查询课程信息接口  /boss/course/getQueryCourses
export const getQueryCourses = data => {
  return request({
    method: 'POST',
    url: '/boss/course/getQueryCourses',
    data
  })
}
// 课程上下架接口 /boss/course/changeState
export const changeState = (data) => {
  return request({
    method: 'GET',
    url: '/boss/course/changeState',
    params: data
  })
}
// 保存或者更新课程信息接口  /boss/course/saveOrUpdateCourse
export const saveOrUpdateCourse = data => {
  return request({
    method: 'POST',
    url: '/boss/course/saveOrUpdateCourse',
    data
  })
}
// 上传图片接口  /boss/course/upload
export const uploadCourseImg = (data, onUploadProgress) => {
  // data 应该是formdata对象
  return request({
    method: 'POST',
    url: '/boss/course/upload',
    data,
    onUploadProgress
    //  onUploadProgress 用于检测上传进度
    // onUploadProgress (thing) {
    //   console.log(thing.loaded, thing.total)
    // }
  })
}
// 通过课程Id获取课程信息接口 /boss/course/getCourseById
export const getCourseById = (courseId) => {
  return request({
    method: 'GET',
    url: '/boss/course/getCourseById',
    params: {
      courseId
    }
  })
}
